"""
面试题:
如何操作下拉框的?
1. 导入select 类
2. 创建下拉框对象
3. 通过对象调用下拉框的方法
"""
# 1. 先创建浏览器驱动对象
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

driver=webdriver.Chrome()
driver.maximize_window()
# 2 通过get方法打开页面
driver.get("http://localhost:8081/regA.html")
#
select=Select(driver.find_element(By.CSS_SELECTOR,"#selectA")) #定位select这个标签
# select.select_by_index(1)  #索引从0开始,不能使用负数
# select.select_by_value("gz")  # 通过value属性值进行定位
select.select_by_visible_text("深圳")




# driver.find_element(By.CSS_SELECTOR,"option[value='gz']").click()
#
# time.sleep(2)
# driver.find_element(By.CSS_SELECTOR,"option[value='sz']").click()
time.sleep(100)

# 4. 关闭浏览器驱动对象
driver.quit()
